"""
@name : 2021-05-29-python运算符与表达式
@author : wenyao
@projectname: xsfh
"""
#算术运算符
#  /  在python3中是真除，python2中是地板除，python2想要真除得将数值转为浮点型
# >>> a = 3
# >>> b = 4
# >>> a + b
# 7
# >>> a - b
# -1
# >>> a * b
# 12
# >>> a / b
# 0.75
# >>> a % b
# 3
# >>> a // b
# 0
# >>> 10 // 3
# 3
# >>> -10 // 3
# -4
# >>> 10 % 3
# 1
# >>> 10 / 3
# 3.3333333333333335

#赋值运算符
# >>> a += 1  #等同于 a = a+1
# >>> a
# 4
# >>> a -= 1
# >>> a
# 3

#比较运算符 x>y, x<y, x>=y, x<=y, x==y, x!=y => True/False
# >>> True == 1
# True
# >>> True == 2
# False
# >>> False == 1
# False
# >>> False == 0
# True
# >>> False < True
# True
# >>> a
# 3
# >>> a * True
# 3
# >>> a * False
# 0
# >>> (a >b) + (a<b)
# 1

#逻辑运算
#短路运算
# >>> c = a>=b and a or b

#对于包含and ， not  ， or的表达式
#表达式从左至右进行运算，若or的左侧逻辑值为True，则短路or后所有的表达式（不管后面是and还是or）
# >>> 3 or print("a") and not print("b") or print("c")
# 3
#若and左侧的逻辑值为false，则短路后所有的and表达式，直到有or出现
# >>> c = 0 or print("a") and not print("b") and not print("c") or print("d")
# a
# d
# >>> print(c)
# None



#成员关系运算符  -- 容器类型  in，not in
# >>> a = "abc"
# >>> "b" in a
# True
# >>> "bc" in a
# True
# >>> "bc" not in a
# False

#对象实例测试关系运算符  is，  not is
# >>> a = "haha"
# >>> a = "%haha"
# >>> b = "%haha"
# >>> a == b
# True
# >>> a is b
# False
# >>> print(id(a))
# 139702549543376
# >>> print(id(b))
# 139702549543432


#位运算符
# >>> 10 & 3
# 2
# >>> 10 | 3
# 11
# >>> 10 ^ 3
# 9
# >>> ~10
# -11
# >>> ~5
# -6
# >>> ~4
# -5
# >>> ~-5
# 4
# >>> 5>>2
# 1
# >>> 5 << 2
# 20
